package com.ulife.permission.dao.impl;

import java.sql.SQLException;
import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.ulife.permission.dao.FunctionDao;
import com.ulife.permission.dao.dataobject.FunctionDO;

public class FunctionDaoImpl extends SqlMapClientDaoSupport implements FunctionDao {

	public FunctionDO getFunctionById(long id) throws SQLException {
		return (FunctionDO)getSqlMapClient().queryForObject("Function.getFunctionById",id);
	}

	public FunctionDO getFunctionByFunctionId(String functionId) throws SQLException {
		return (FunctionDO)getSqlMapClient().queryForObject("Function.getFunctionByfunctionId",functionId);
		}

	public int addFunction(FunctionDO function) throws SQLException {
		return getSqlMapClient().update("Function.insertFunction",function);
	}

	@SuppressWarnings("unchecked")
	public List<FunctionDO> getAllFunction() throws SQLException {
		return getSqlMapClient().queryForList("Function.selectAllFunctions");
	}

	public int updateFunction(FunctionDO functionDO) throws SQLException {
		return getSqlMapClient().update("Function.updateFunction", functionDO);
	}

}
